//数据请求层
//封装接口方法
import {
  axiosPost
} from '../libs/https';

//获取当天详细信息
function getDayData(date) {
  return new Promise((resolve, reject) => {
    axiosPost({
      //http://v.juhe.cn/calendar/day?date=2015-1-1&key=您申请的appKey
      url: '/api/calendar/day',
      data: {
        date
      },
      success(data) {
        resolve(data);
      },
      error(err) {
        reject(err);
      }
    })
  })
}

//获取近期月份详细信息
function getMonthData(yearMonth) {
  return new Promise((resolve, reject) => {
    axiosPost({
      //http://v.juhe.cn/calendar/day?date=2015-1-1&key=您申请的appKey
      url: '/api/calendar/month',
      data: {
        'year-month': yearMonth
      },
      success(data) {
        resolve(data);
      },
      error(err) {
        reject(err);
      }
    })
  })
}

//获取当年的假期列表
function getYearData(year) {
  return new Promise((resolve, reject) => {
    axiosPost({
      //http://v.juhe.cn/calendar/day?date=2015-1-1&key=您申请的appKey
      url: '/api/calendar/year',
      data: {
        year
      },
      success(data) {
        resolve(data);
      },
      error(err) {
        reject(err);
      }
    })
  })
}

export {
  getDayData,
  getMonthData,
  getYearData
}